package cn.anc.aonicardv.util;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;


import cn.anc.aonicardv.R;
import cn.anc.aonicardv.widget.WarningDialog;

/**
 * Created by yangdai on 2017/8/12.
 */

public class DialogUtils {

    @Deprecated
    public AlertDialog.Builder getAlertDialog(Context context) {
        int theme;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH) {
            theme = R.style.DialogButton_api19;
        } else
            theme = R.style.DialogButton;
        AlertDialog.Builder builder = new AlertDialog.Builder(context, theme);
        builder.setCancelable(false);
        return builder;
    }

    public AlertDialog.Builder getCustomMessageAlertDialog(Context context, int res) {
        int theme;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH) {
            theme = R.style.DialogButton_api19;
        } else
            theme = R.style.DialogButton;
        AlertDialog.Builder builder = new AlertDialog.Builder(context, theme);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_alert, null);
        TextView textView = view.findViewById(R.id.tv_msg);
        textView.setText(res);
        builder.setView(view);
        builder.setCancelable(false);
        return builder;
    }

    public Dialog getCustomProgressDialog(Context context) {
        Dialog progressDialog = new Dialog(context, R.style.CustomProgressDialogStyle);
        progressDialog.setContentView(R.layout.dialog_progress);
        progressDialog.setCancelable(true);
        progressDialog.setCanceledOnTouchOutside(false);
        return progressDialog;
    }

    public ProgressDialog getProgressDialog(Context context) {
        ProgressDialog progressDialog = new ProgressDialog(context);
        progressDialog.setCancelable(false);
        progressDialog.setCanceledOnTouchOutside(false);
        return progressDialog;
    }

    public WarningDialog getWarningDialog(Context context) {
        WarningDialog warningDialog = new WarningDialog(context, R.style.BaseDialogStyle);
        return warningDialog;
    }


}
